package entity;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;

import constans.Globals;
import constans.ResourceManager;
import engine.Map;

public class Entity {
	
	public static final int BUILDING = 1;
	public static final int UNIT = 2;
	public static final int BULLET = 3;
	int type;
	float x;
	float y;
	int i;
	int j;
	int size = 30;
	int time;
	protected Image img;
	
	protected boolean picked;
	
	public Entity()
	{
		time = 0;
	}
	public Entity(int x, int y)
	{
		time = 0;
		setPosition(x,y);
	}
	
	public void render(GameContainer container, Graphics g) throws SlickException
	{	
	}
	public void update(GameContainer container, int delta) throws SlickException
	{
	
	}
	
	public void setPosition(int x, int y)
	{	
		this.x = (x + Globals.MAP_START) / Globals.FIELD_SIZE * Globals.FIELD_SIZE - Globals.MAP_START;
		this.y = (y + Globals.MAP_START) / Globals.FIELD_SIZE * Globals.FIELD_SIZE - Globals.MAP_START;
	
		i = (int) (this.x/Globals.FIELD_SIZE);
		j = (int) (this.y/Globals.FIELD_SIZE);
	}
	public float getX() {
		return x;
	}
	public float getY() {
		return y;
	}
	public float getCenterX() {
		return x+size/2;
	}

	public float getCenterY() {
		return y+size/2;
	}
	public int getI() {
		return i;
	}

	public int getJ() {
		return j;
	}
	public int getType()
	{
		return type;
	}
	public void time()
	{
		time++;
		if(time == 1000)
			time = 0;
	}
	public void setPicked(boolean b)
	{
		picked = b;
	}
}
